﻿<cfsilent>
	<cfscript>

		sessionAdvice = getProperty("serviceFactory").getBean("sessionAdvice");
		dictAdvice = getProperty("serviceFactory").getBean("senateDictionaryAdvice");
		pageAdvice = getProperty("serviceFactory").getBean("pageAdvice");

		teacherId = sessionAdvice.getAutherUserID();
		
		hashCode = event.getArg("Sign");
		taskId = event.getArg("TSK");
		taskType = event.getArg("TT");

		checked = false;
		
		try {
			
			if ( decrypt(hashCode, teacherId, "PBEWithMD5AndDES", "Hex") eq taskId ) {
				
				/* 载入补考教学任务 */
				
				sql = "SELECT 
							a.mark_need,a.mark_done,
							b.mark_mode,a.task_prog
						FROM
							t_resitplan a
							INNER JOIN t_course b ON a.cid = b.cid
						WHERE
							a.task_id = :taskId";
							
				queryObj = new query( datasource=application.dnsSlave );
				
				queryObj.addParam( name="taskId",value=taskId,cfsqltype="cf_sql_varchar");
				
				rs_task = queryObj.execute( sql=sql ).getResult();
				
			
				progress = 0;
					
				if ( rs_task.mark_need ) {
					progress = int( rs_task.mark_done * 10000 / rs_task.mark_need ) / 100;
				}

				/* 生成分页 */
				pageAdvice.setTotleRow( rs_task.mark_need );
				pageAdvice.setStartRow( event.getArg("Start", 1) );
				pageAdvice.setPage( event.getArg("Page", 1) );
				
				pageAdvice.setRowPerPage( 30 );
				
				pageArray = pageAdvice.getPageList();
				
				if ( rs_task.mark_mode eq "2" and ( rs_task.task_prog eq "1" or rs_task.task_prog eq "2" ) ) {
					
					checked = true;
					
					/* 更新成绩提交状态 */
					transaction {
						sql = "UPDATE
									t_resitplan
								SET
									task_prog = '2'
								WHERE
									task_id = :taskId";
									
						queryObj = new query( datasource=application.dnsMaster );
						
						queryObj.addParam( name="taskId",value=taskId,cfsqltype="cf_sql_varchar");
						
						queryObj.execute( sql=sql );

					}
					
					/* 传递参数处理 */
					pageArgs = structNew();
					structInsert( pageArgs, "TSK", taskId, true );
					structInsert( pageArgs, "TT", taskType, true );
					structInsert( pageArgs, "Sign", encrypt(taskId, teacherId, "PBEWithMD5AndDES", "Hex"), true );

					targetArgs = structNew();
					structInsert( targetArgs, "TSK", taskId, true );
					structInsert( targetArgs, "TT", taskType, true );
					structInsert( targetArgs, "Sign", encrypt(taskId, teacherId, "PBEWithMD5AndDES", "Hex"), true );

					/* 载入成绩提交名单 */
					sql = "SELECT 
							a.scc_id,
							b.stu_id,b.stu_name,
							c.cls_name,d.sbj_short,
							a.mark_resit,a.mark_renote
						FROM
							t_temp_mark_resit a
							INNER JOIN t_student b ON b.stu_id = a.stu_id
							INNER JOIN t_class c ON c.cls_id = b.cls_id
							INNER JOIN t_subject d ON d.sbj_id = c.sbj_id
						WHERE
							a.task_id = :taskId 
						ORDER BY 
							b.stu_id";
								
					queryObj = new query( datasource=application.dnsSlave );
					
					queryObj.addParam( name="taskId",value=taskId,cfsqltype="cf_sql_varchar");
					
					rs_student = queryObj.execute( sql=sql ).getResult();
					
					
					/* 载入特殊情况成绩提交名单 */
					sql = "SELECT 
							a.scc_id,
							b.stu_id,b.stu_name,
							c.cls_name,d.sbj_short,
							a.mark_resit,a.mark_renote
						FROM
							t_temp_mark_resit a
							INNER JOIN t_student b ON b.stu_id = a.stu_id
							INNER JOIN t_class c ON c.cls_id = b.cls_id
							INNER JOIN t_subject d ON d.sbj_id = c.sbj_id
						WHERE
							a.task_id = :taskId 
							AND 
							(
								( a.mark_renote = '1' AND a.mark_resit < 60 )
								OR
								( a.mark_renote < '1' OR a.mark_renote > '1' )
							)
						ORDER BY 
							b.stu_id";
								
					queryObj = new query( datasource=application.dnsSlave );
					
					queryObj.addParam( name="taskId",value=taskId,cfsqltype="cf_sql_varchar");
					
					rs_spec = queryObj.execute( sql=sql ).getResult();
					
					
					
				startRow = pageAdvice.getStartRow();
				endRow = startRow + pageAdvice.getRowPerPage() - 1;
				}
				
			}
				
		}
		catch (any ecpt) {
		}
		
		/* 判断当前显示课表内容 */
		currentTab = event.getArg("TabID", "labSheet");
		
		if ( rs_spec.recordCount ) {
			currentTab = event.getArg("TabID", "labSpec");
		}
	
	</cfscript>
</cfsilent>

<cfif checked >
	
		<div class="UItab">
			<div class="tabLables">
				<span <cfif currentTab eq "labSheet">class="active"</cfif> id="labSheet" tabTarget="Sheet">录入成绩核查</span>
				<cfif rs_spec.recordCount >
					<span <cfif currentTab eq "labSpec">class="active"</cfif> id="labSpec" tabTarget="Spec">特殊成绩</span>
				</cfif>
			</div>
		</div>
		<script language="javascript" type="text/javascript">
			//<![CDATA[
			<!--
			$(document).ready(function() {
						
				/* init Tab */
				$("div.tabContent").hide();
				$("div#" + $("div.tabLables span.active").attr("tabTarget")).show();
				
				$("div.tabLables > span").click(function(){
					var $targetID = $(this).attr("tabTarget");
						
					$("div.tabLables span").removeClass("active");
					$(this).addClass("active");
							
					$("div.tabContent").not('[id="' + $targetID + '"]').hide();
					$("div.tabContent#" + $targetID).show();
				});
						
			});
			// -->
			//]]>
		</script>

		<div id="Sheet" class="tabContent">
			
			<div class="noticeBlock">
				<h3>课程补考成绩</h3>
				<p>
					<span class="img icon16x16 message"></span>
					请注意, 这里需要提交的是课程考核成绩. 当前课程成绩按照二级制提交, 课程考核结果应当填写为 通过/未通过 . 同时请注意缺考和缓考标注.
				</p>
				<hr/>
			</div>
			
			<cfif progress eq 100>
			
				<!--- 如果计分完成, 则显示跳转到成绩检查页面 --->
				<div id="complateNotice" class="systemNotice">
					<h3><span class="img icon16x16 info"></span>成绩核对</h3>
					<p>注意: 您需要在学校规定的时间内完成教学任务的成绩提交. </p>
					<p>请在正式提交成绩之前, 仔细核对录入成绩是否完全正确. 成绩一旦正式提交, 将不可再次更改. </p>
					<form id="formRemove" class="formWrapper Transparent" method="post" action="<cfoutput>#buildURL('taskMarkResitWizardSubmit')#</cfoutput>">
						<input type="hidden" name="TSK" value="<cfoutput>#taskId#</cfoutput>" />
						<input type="hidden" name="TT" value="<cfoutput>#taskType#</cfoutput>" />
						<input type="hidden" name="Sign" value="<cfoutput>#encrypt(taskId, teacherId, 'PBEWithMD5AndDES', 'Hex')#</cfoutput>" />
						<div class="lable"><input class="button2" type="submit" value="正式提交成绩" /></div>
					</form>
				</div>
			
			
				<table class="UIEditable">
					<thead>
						<tr>
							<td width="30"></td>
							<td>学号</td>
							<td>姓名</td>
							<td>班级</td>
							<td>专业</td>
							<td width="50">成绩</td>
							<td width="25"></td>
						</tr>
					</thead>
					<tbody>
					
						<cfset row = pageAdvice.getOffset() />
						<cfloop startrow="#startRow#" endrow="#endRow#" query="rs_student">
						
							<cfset row++ />
							<cfset structInsert( targetArgs, "Start", pageAdvice.getStartRow(), true ) />
							<cfset structInsert( targetArgs, "Page", pageAdvice.getPage(), true ) />
							<cfset structInsert( targetArgs, "Target", rs_student.scc_id, true ) />
						
							<tr class="editRows studyType<cfoutput>#rs_student.mark_resit#</cfoutput>">
							
								<td class="index"><cfoutput>#row#</cfoutput></td>
								<td><span class="numeric"><cfoutput>#rs_student.stu_id#</cfoutput></span></td>
								<td><cfoutput>#rs_student.stu_name#</cfoutput></td>
								<td><cfoutput>#rs_student.cls_name#</cfoutput></td>
								<td><cfoutput>#rs_student.sbj_short#</cfoutput></td>
							
								<td>
									<cfif rs_student.mark_renote eq "1">
										<cfif rs_student.mark_resit gte 60><span class="markNoteY">合格</span><cfelse><span class="markNoteN">不合格</span></cfif>
										<cfelseif rs_student.mark_renote eq "2">
										<span class="markNote<cfoutput>#rs_student.mark_renote#</cfoutput>">缺考</span>
										<cfelseif rs_student.mark_renote eq "3">
										<span class="markNote<cfoutput>#rs_student.mark_renote#</cfoutput>">缓考</span>
										<cfelseif rs_student.mark_renote eq "9">
										<span class="markNote<cfoutput>#rs_student.mark_renote#</cfoutput>">违纪</span>
									</cfif>
								</td>

								<td><a href="<cfoutput>#buildURL('taskMarkResitWizardMode2', targetArgs)#</cfoutput>" class="stat operation"></a></td>
							
							</tr>
						</cfloop>
					
					</tbody>
				</table>
			
				<div class="pagination">
					<div class="summary">Page:<cfoutput>#pageAdvice.getPage()#</cfoutput>/<cfoutput>#pageAdvice.getPageCount()#</cfoutput> Totle:<cfoutput>#pageAdvice.getTotleRow()#</cfoutput></div>
					<div class="lists">
						<cfloop from="1" to="#arrayLen(pageArray)#" index="page">

							<cfset structInsert( pageArgs, "Start", pageArray[page][2], true ) />
							<cfset structInsert( pageArgs, "Page", pageArray[page][3], true ) />

							<cfswitch expression="#pageArray[page][1]#">
								<cfcase value="D">
									<a href="<cfoutput>#buildURL(event.getName(), pageArgs)#</cfoutput>"><cfoutput>#pageArray[page][3]#</cfoutput></a>
								</cfcase>
								<cfcase value="C">
									<span><cfoutput>#pageArray[page][3]#</cfoutput></span>
								</cfcase>
								<cfcase value="F">
									<a href="<cfoutput>#buildURL(event.getName(), pageArgs)#</cfoutput>">First</a>
								</cfcase>
								<cfcase value="P">
									<a href="<cfoutput>#buildURL(event.getName(), pageArgs)#</cfoutput>">Previous</a>
								</cfcase>
								<cfcase value="N">
									<a href="<cfoutput>#buildURL(event.getName(), pageArgs)#</cfoutput>">Next</a>
								</cfcase>
								<cfcase value="L">
									<a href="<cfoutput>#buildURL(event.getName(), pageArgs)#</cfoutput>">Last</a>
								</cfcase>
							</cfswitch>
						</cfloop>
					</div>
				</div>
			
			<cfelse>
			
				<div class="systemNotice">
					<p>您尚未完成成绩录入</p>
					<ol>
						<li>请完成全部课程成绩录入后再重新进行成绩检查, <a href="<cfoutput>#buildURL('taskMarkResitWizardMode2', targetArgs)#</cfoutput>">点这里继续进行成绩录入</a></li>
					</ol>
				</div>
			
			</cfif>
		</div>
		
		<cfif rs_spec.recordCount>
			
			<div id="Spec" class="tabContent">
				
				<div class="noticeBlock">
					<h3>其他成绩核实</h3>
					<p>
						<span class="img icon16x16 message"></span>
						请注意, 这里列出的仅仅是 不合格, 缓考, 缺考, 违纪等特殊情况成绩的列表.
					</p>
					<hr/>
				</div>
				
				<table class="UIEditable">
				<thead>
					<tr>
						<td width="30"></td>
						<td>学号</td>
						<td>姓名</td>
						<td>班级</td>
						<td>专业</td>
						<td width="50">成绩</td>
						
					</tr>
				</thead>
				<tbody>
					
					<cfset row1 = 0 />
					<cfloop startrow="#startRow#" endrow="#endRow#" query="rs_spec">
						
						<cfset row1++ />
						
						<tr class="editRows studyType<cfoutput>#rs_spec.mark_resit#</cfoutput>">
							
							<td class="index"><cfoutput>#row1#</cfoutput></td>
							<td><span class="numeric"><cfoutput>#rs_spec.stu_id#</cfoutput></span></td>
							<td><cfoutput>#rs_spec.stu_name#</cfoutput></td>
							<td><cfoutput>#rs_spec.cls_name#</cfoutput></td>
							<td><cfoutput>#rs_spec.sbj_short#</cfoutput></td>
							
							<td>
								<cfif rs_spec.mark_renote eq "1">
									<cfif rs_spec.mark_resit gte 60><span class="markNoteY">合格</span><cfelse><span class="markNoteN">不合格</span></cfif>
									<cfelseif rs_spec.mark_renote eq "2">
									<span class="markNote<cfoutput>#rs_spec.mark_renote#</cfoutput>">缺考</span>
									<cfelseif rs_spec.mark_renote eq "3">
									<span class="markNote<cfoutput>#rs_spec.mark_renote#</cfoutput>">缓考</span>
									<cfelseif rs_spec.mark_renote eq "9">
									<span class="markNote<cfoutput>#rs_spec.mark_renote#</cfoutput>">违纪</span>
								</cfif>
							</td>
							
							
							
						</tr>
					</cfloop>
					
				</tbody>
			</table>
				
			</div>
			
		</cfif>
		
	<cfelse>
	
		<div class="systemNotice">
			<h3><span class="img icon16x16 message"></span>错误的参数</h3>
			<p>请关闭浏览器重新登录 或 检查您是否使用了正确访问方式</p>
		</div>
</cfif>

